﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace bat_sym.Helpers
{
    public class ParameterDictionary : ICollection
    {
        public class Parameter : ViewModelBase
        {
            private string _name;
            private double _val;

            public string Name 
            {
                get
                {
                    return _name;
                }

                set
                {
                    _name = value;
                    NotifyPropertyChanged("Name");
                }
            }

            public double Value
            {
                get
                {
                    return _val;
                }

                set
                {
                    _val = value;
                    NotifyPropertyChanged("Value");
                }
            }
        }

        private List<Parameter> _params;

        public ParameterDictionary()
        {
            _params = new List<Parameter>();
        }

        public void Add(string name, double value)
        {
            _params.Add(new Parameter { Name = name, Value = value });
        }

        public Parameter Get(string name)
        {
            var obj = _params.FirstOrDefault(x => x.Name == name);
            return obj;
        }

        public double this[string name]
        {
            get
            {
                var obj = _params.FirstOrDefault(x => x.Name == name);
                return obj.Value;
            }
            
            set
            {
                var obj = _params.FirstOrDefault(x => x.Name == name); 
                obj.Value = value;
            }
        }

        public void CopyTo(Array array, int index)
        {
            throw new NotImplementedException();
        }

        public int Count
        {
            get { return _params.Count; }
        }

        public bool IsSynchronized
        {
            get { throw new NotImplementedException(); }
        }

        public object SyncRoot
        {
            get { throw new NotImplementedException(); }
        }

        public IEnumerator GetEnumerator()
        {
            return _params.GetEnumerator();
        }
    }
}
